package org.lyon_yan.JBCS_framework;

import org.lyon_yan.JBCS_framework.config.R;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;

/**
 * APP启动项，入口函数
 * 
 * @author Lyon_Yan
 * @since 2015-08-06 09:51:57
 * @version 8.0.1
 */
public abstract class AppInit extends Application {

	@Override
	public void start(Stage primaryStage) throws Exception {
		// TODO Auto-generated method stub
		primaryStage.setTitle(R.value.stageTitle);
		try {
			if (R.image.icon_png != null) {
				primaryStage.getIcons().add(new Image(R.image.icon_png));
			}
		} catch (Exception e) {
			// TODO: handle exception
		}
		primaryStage.setScene(new Scene(onPreCreate(primaryStage),
				R.dimens.sceneWidth, R.dimens.sceneHeight));
		primaryStage.show();
	}

	protected abstract Pane onPreCreate(Stage primaryStage);

	/**
	 * The main() method is ignored in correctly deployed JavaFX application.
	 * main() serves only as fallback in case the application can not be
	 * launched through deployment artifacts, e.g., in IDEs with limited FX
	 * support. NetBeans ignores main().
	 *
	 * @param args
	 *            the command line arguments
	 */
	public static void main(String[] args) {
		launch(args);
	}
}
